package sso.util;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;

public class WebUtils {
    public static void writeJson2Client(HttpServletResponse httpServletResponse, Map<String ,Object> map) throws IOException {
        httpServletResponse.setCharacterEncoding("utf-8");
        httpServletResponse.setContentType("application/json;charset=utf-8");
        String s = new ObjectMapper().writeValueAsString(map);
        PrintWriter writer = httpServletResponse.getWriter();
        System.out.println(s);
        writer.println(s);
        writer.flush();
    }
}